<div class="division">
	<span><{t}>付款人<{/t}></span>
	<{if $coms}>
	<ul>  
		<{foreach from=$coms item=com key=key name=name}>
		<li>
			<label>
				<input type="radio" name="company_id" value="<{$com.company_id}>"<{if $smarty.foreach.name.iteration == 1 || $com.def_company==1}> checked<{/if}>>
				<{$com.name}>&nbsp;<{if $com.c_type==3}><{$com.inn_p}><{else}><{$com.inn}><{/if}>
				&nbsp;<a href="javascript:void(0)" class="lnk companyedit"><{t}>编辑<{/t}></a>
			</label>
		</li>
		<{/foreach}>
		<li>
			<label><input type="radio" name="company_id" value="0"><{t}>其他<{/t}></label>
		</li>
		<li>
			<div id="checkout-company" style='display:none'></div>
		</li>
	</ul>
	<{else}>
		<div id='checkout-company'>
			<{include file="admin/order/company_info.html"}>
		</div>
	<{/if}>
 </div>
<script>
window.addEvent('domready',function(){
	var url_area3 = 'index.php?app=b2c&ctl=admin_order&act=getCompany';

    var addlistRadios3=$$('input[name^=company_id','receiver');
    if(addlistRadios3.length){

        addlistRadios3.addEvent('click', function(e,edit){
                this.set('checked',true);
                var _value=this.value;

                if(_value!='0'){
                    if(edit){
                       $('checkout-company').show();
                    }
                    else $('checkout-company').hide();
                }else{
                    $('checkout-company').show();
				}


                new Request.HTML({
                    url:url_area3,
                    update:'checkout-company',
                    onRequest:function(){
                      $('checkout-company').set('html','<div class="font-green">loading...</div>');
                    },
                    onComplete:function(){

                    }}).get({'company_id':_value,'member_id':$E('input[name^=member_id]').getValue()?$E('input[name^=member_id]').getValue():null});
            });

		if ($E('input[name^=def_company]') == null)
			addlistRadios3[0].fireEvent('click');
		else
		{
			addlistRadios3.each(function(el, index){
				if ($(el).getValue() == $E('input[name^=def_company]').getValue())
				{
					addlistRadios3[index].fireEvent('click');
				}
			});
		}
       addlistRadios3.getLast().addEvent('click',$('checkout-company').show.bind($('checkout-company')));
   }

	$$('.companyedit','receiver').addEvent('click', function(e){
		e.stop();
		this.getPrevious('input[name^=company_id').fireEvent('click',[e,true]);
	});

});
</script>
